export default class UseUploadImg {
  public options: UniApp.ChooseImageOptions = {
    count: 1,
    sizeType: ["original", "compressed"], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ["album", "camera"], //从相册、相机选择
  };

  constructor(options?: UniApp.ChooseImageOptions) {
    this.options = {
      ...this.options,
      ...options,
    };
  }

  // 上传
  uploadImg = () => {
    return new Promise<UniApp.ChooseImageSuccessCallbackResult>((resolve, reject) => {
      uni.chooseImage({
        ...this.options,
        success: (res) => resolve(res),
        error: (e: Error) => reject(e),
      });
    });
  };
}
